#ifndef __PRIMITIVE_MANAGER__
#define __PRIMITIVE_MANAGER__

class PrimitiveManager : Dispatcher {
public:
	void AddPrimitive(Primitive* p, const std::string& label);
	void RemovePrimitive(Primitive* p);
	void Clear();
	PrimitiveRenderer* GetCurrentPrimitiveRenderer();
	Primitive* GetCurrentPrimitive();
	PrimitiveRenderer* GetPrimitiveRenderer(size_t i);
	Primitive* GetPrimitive(size_t i);
	size_t Size() const;
	void Update();
	void Render() const;
	static PrimitiveManager* Instance();
private:
	std::vector<PrimitiveRenderer*> primitive;

	PrimitiveManager();
	PrimitiveManager(PrimitiveManager const&){};
	PrimitiveManager& operator=(PrimitiveManager const&){return *this;}
	static PrimitiveManager* instance;

	void InitializeRenderer(Primitive* primitive);
	virtual void Visit(Surface* surface);
	virtual void Visit(STriangleMesh* tm);
	virtual void Visit(NurbsSurfaceMesh* mesh);
	virtual void Visit(Curve* curve);
};

#endif //__PRIMITIVE_MANAGER__
